<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')"/>
</head>
<style>

</style>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label style="width: 120px;">订单流水号</label>
                            <input type="text" name="orderNo"/>
                        </li>
                        <li>
                            <label style="width: 120px;">服务商编号</label>
                            <input type="text" name="customerNum"/>
                        </li>
                        <li>
                            <label style="width: 120px;">所属资深总监编号</label>
                            <input type="text" name="belongAgent"/>
                        </li>
                        <li>
                            <label style="width: 120px;">所属资深总监名称</label>
                            <input type="text" name="belongName"/>
                        </li>
                        <li>
                            <label style="width: 120px;">收货人姓名</label>
                            <input type="text" name="takeName"/>
                        </li>
                        <li>
                            <label style="width: 120px;">收货人手机号</label>
                            <input type="text" name="takePhone" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" />
                        </li>

                        <li>
                            <label style="width: 120px;">支付状态</label>
                            <select name="traceStatus">
                                <option value="">所有</option>
                                <option value="0">成功</option>
                                <option value="1">失败</option>
                                <option value="2">待支付</option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 120px;">支付流水号</label>
                            <input type="text" name="outTradeNo"/>
                        </li>
                        <li>
                            <label style="width: 120px;">支付方式</label>
                            <select name="paymentWay">
                                <option value="">所有</option>
                                <option value="1">微信</option>
                                <option value="2">支付宝</option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 120px;">订单状态</label>
                            <select name="orderStatus">
                                <option value="">所有</option>
                                <option value="1">待收货</option>
                                <option value="2">已完成</option>
                                <option value="3">待发货</option>
                                <option value="4">待付款</option>
                                <option value="5">已取消</option>
                                <option value="6">已退款</option>
                            </select>
                        </li>
                        <li class="select-time">
                            <label style="width: 120px;">交易日期：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始日期" name="params[beginAddTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束日期" name="params[endAddTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <!--订单层-->
        <!--发货层-->
        <div class="wrapper" id="delivery" style=" display:none">
            <form class="form-horizontal m" id="form2" method="post" enctype="multipart/form-data">
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">快递公司：</label>
                            <div class="col-sm-8">
                                <select id="expressId" class="province form-control m-b">
                                    <option value="">选择快递</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">快递单号：</label>
                            <div class="col-sm-8">
                                <input type="text" id="expressOrderNo" placeholder="快递单号" class="form-control">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">活动：</label>
                            <div class="col-sm-8">
                                <input name="actName" onclick="selectAct()" readonly id="actName" type="text"
                                       class="form-control">
                                <input name="actId" id="actId" type="hidden">
                                <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">截止时间：</label>
                            <div class="col-sm-8">
                                <input name="endDate" id="endDate" readonly class="form-control time-input" placeholder="yyyy-MM-dd"
                                       type="text">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-required">激活返现：</label>
                            <div class="col-sm-8">
                                <select id="activeType" name="activeType"  class="form-control" >
                                    <option value="1">反下级</option>
                                    <option value="0">反本级</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-required">达标返现：</label>
                            <div class="col-sm-8">
                                <select id="standardType" name="standardType"  class="form-control" >
                                    <option value="1">反下级</option>
                                    <option value="0">反本级</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-required">阶段达标返现：</label>
                            <div class="col-sm-8">
                                <select id="stageStandardType" name="stageStandardType"  class="form-control" >
                                    <option value="1">反下级</option>
                                    <option value="0">反本级</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-required">流量费返现：</label>
                            <div class="col-sm-8">
                                <select id="flowType" name="flowType"  class="form-control" >
                                    <option value="1">反下级</option>
                                    <option value="0">反本级</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label is-required">服务费返现：</label>
                            <div class="col-sm-8">
                                <select id="serviceType" name="serviceType"  class="form-control" >
                                    <option value="1">反下级</option>
                                    <option value="0">反本级</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">划拨类型：</label>
                            <div class="col-sm-6" style="margin-top: 5px;">
                                <label style="text-align: center"> <input type="radio" onchange="javascript:window.onchangeRadio(this)" name="hbType" value="1"/> SN编号 </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <label style="text-align: center"> <input type="radio" onchange="javascript:window.onchangeRadio(this)" name="hbType" value="2"/> 文件导入</label>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group" id="excel" style="display: none">
                            <label class="col-sm-3 control-label is-required">终端文件：</label>
                            <div class="col-sm-5">
                            <span class="btn btn-white btn-file">
                                <input required style="width: 198px;" type="file" name="file" id="file"
                                       accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"/>
                            </span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group" id="sn" style="display: none">
                            <div class="form-inline">
                                <label class="col-sm-3 control-label is-required">SN编号：</label>
                                <div class="col-sm-6">
                                    <input type="text" style="width: 185px;" class="form-control" id="startSn" name="startSn">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-9">
                        <div class="form-group">
                            <label class="col-xs-2 control-label">备注：</label>
                            <div class="col-xs-10">
                                <textarea id="service_remarks" name="takeAddress" style="width: 730px;" placeholder="客服备注"
                                          class="form-control"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>


        <!--修改收货地址-->
        <div class="wrapper" id="editArea" style=" display:none">
            <form class="form-horizontal m" id="form1">
                <div class="form-group">
                    <label class="col-sm-3 control-label">订单编号：</label>
                    <div class="col-sm-6">
                        <input type="text" id="orderNo" name="orderNo" placeholder="订单编号" class="form-control">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">收货人：</label>
                    <div class="col-sm-6">
                        <input type="text" id="takeName" name="takeName" placeholder="收货人" class="form-control">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">手机号：</label>
                    <div class="col-sm-6">
                        <input type="text" id="takePhone" name="takePhone" placeholder="手机号" class="form-control">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">区域：</label>
                    <div class="col-sm-2">
                        <select name="province" onchange="javascript:window.province('p')" id="province"
                                class="province form-control m-b">
                            <option value="">选择省</option>
                        </select>
                    </div>
                    <div class="col-sm-2">
                        <select name="city" id="city" onchange="javascript:window.province('c')"
                                class="province form-control m-b">
                            <option value="">选择市</option>
                        </select>
                    </div>
                    <div class="col-sm-2">
                        <select name="area" id="area" onchange="javascript:window.province('a')"
                                class="province form-control m-b">
                            <option value="">选择区</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">收货地址：</label>
                    <div class="col-sm-6">
                            <textarea id="takeAddress" name="takeAddress" placeholder="收货地址" class="form-control">

                            </textarea>
                    </div>
                </div>
            </form>
        </div>


        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary single disabled" onclick="editArea()"
               shiro:hasPermission="ShopOrder:ShopOrder:edit">
                <i class="fa fa-edit"></i> 修改收货信息
            </a>
            <a class="btn btn-primary single disabled" onclick="delivery()"
               shiro:hasPermission="ShopOrder:ShopOrder:edit">
                <i class="fa fa-edit"></i> 发货并划拨
            </a>

            <a class="btn btn-primary single disabled" onclick="hb()" shiro:hasPermission="ShopOrder:ShopOrder:edit">
                <i class="fa fa-edit"></i> 查看划拨记录
            </a>

            <a class="btn btn-success" onclick="cj()" shiro:hasPermission="terminal:record:revoke">
                <i class="fa fa-plus"></i> 撤机
            </a>
            <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ShopOrder:ShopOrder:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ShopOrder:ShopOrder:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ShopOrder:ShopOrder:remove">
                <i class="fa fa-remove"></i> 删除
            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" class="table text-nowrap"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('ShopOrder:ShopOrder:edit')}]];
    var removeFlag = [[${@permission.hasPermi('ShopOrder:ShopOrder:remove')}]];
    var prefix = ctx + "ShopOrder/ShopOrder";
    var paymentWay = [[${@dict.getType('paymentWay')}]];
    var orderStatus = [[${@dict.getType('orderStatus')}]];


    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "订单",
            clickToSelect: true,
            columns: [{
                radio: true
            },
                {
                    field: 'customerNum',
                    title: '服务商编号'
                },
                {
                    field: 'belongAgent',
                    title: '所属资深总监编号'
                },
                {
                    field: 'belongName',
                    title: '所属资深总监名称'
                },
                {
                    field: 'orderNo',
                    title: '订单流水号'
                },
                {
                    field: 'totalAmount',
                    title: '订单总金额'
                },
                {
                    field: 'goodsNum',
                    title: '订单机具(台)'
                },
                {
                    field: 'traceDate',
                    title: '支付日期',
                    formatter: function (value, row, index) {
                        if (null==row.traceDate){
                            row.traceDate='';
                        }
                        if (null==row.traceTime){
                            row.traceTime='';
                        }
                        if (''== row.traceDate && ''==row.traceTime){
                            return '<span style="color: grey">暂无</span>'
                        }else{
                            return row.traceDate +' ' + row.traceTime;
                        }

                    }
                },
                {
                    field: 'takeName',
                    title: '收货人姓名',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 5);
                    }
                },
                {
                    field: 'takePhone',
                    title: '收货人手机号'
                },
                {
                    field: 'takeAddress',
                    title: '收货地址',
                    formatter: function (value, row, index) {
                        return  row.area + " " + value;
                    }
                },


                {
                    field: 'remarks',
                    title: '用户备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 5);
                    }
                },
                {
                    field: 'customerRemarks',
                    title: '客服备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 6);
                    }
                },
                {
                    field: 'mianTitle',
                    title: '商品名称',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 5);
                    }
                },
                {
                    field: 'goodsPrice',
                    title: '商品单价'
                },
                {
                    field: 'updateDate',
                    title: '更新时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 6);
                    }
                },
                {
                    field: 'createDate',
                    title: '创建时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 6);
                    }
                },
                {
                    field: 'outTradeNo',
                    title: '支付流水号',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 5);
                    }
                },
                {
                    field: 'paymentWay',
                    title: '支付方式',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(paymentWay, value);
                    }
                },
                {
                    field: 'orderStatus',
                    title: '订单状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(orderStatus, value);
                    }
                },
                {
                    field: 'hbRecord',
                    title: '划拨状态',
                    formatter: function (value, row, index) {
                        if (row.hbRecord == 0) {
                            return '<span class="label label-danger">未划拨</span>';
                        } else if (row.hbRecord == 1) {
                            return '<span class="label label-success">已划拨</span>';
                        } else if (row.hbRecord == 2) {
                            return '<span class="label label-danger">已撤销</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }
                    },
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="queryOrder(\'' + row.orderNo + '\')"><i class="fa fa-edit"></i>查看物流</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#laydate-trace_time',
                type: 'time',
                trigger: 'click'
            });
        });
    });


    /**
     *初始化省
     */
    function initProvince() {
        var url = ctx + "area/area/list";
        $.post(url, {'areaType': '0'}, function (result) {
            if (result.code == '0') {
                initSelect("province", result);
            }
        });
    }

    /**
     *
     * @param type 传入 省 p 市 c 区 a
     */
    function province(type) {
        var url = ctx + "area/area/list"; //获取地址信息
        if (type == 'p') {  //联动市
            if ($("#province").find("option:selected").val() == '') {
                defaultOption("city", "请选择市");
                defaultOption("area", "请选择区");
            } else {
                $.post(url, {'parentId': $("#province").val()}, function (result) {
                    if (result.code == '0') {
                        initSelect("city", result);
                    }
                });
            }
        } else if (type == 'c') {  //联动县
            $.post(url, {'parentId': $("#city").val()}, function (result) {
                if (result.code == '0', result) {
                    initSelect("area", result);
                }
            });
        }
    }

    //初始化 select选项
    function initSelect(selectId, data) {
        //清空旧的数据
        if (selectId != 'province') {
            $("#" + selectId).empty();
        }
        var option = '';
        data.rows.forEach(function (value) {
            option += "<option value='" + value.areaCode + "'>" + value.areaName + "</option>";
        });
        $("#" + selectId).append(option);
    }

    //初始化 select选项
    function defaultOption(selectId, text) {
        $("#" + selectId).empty();
        $("#" + selectId).append("<option value=''>" + text + "</option>");
    }

    //修改收货人信息
    function editArea(obj) {
        var orderNo = $.table.selectColumns("orderNo");
        if (orderNo.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        } else if (orderNo.length > 1) {
            $.modal.alertWarning("只能选择一条记录");
            return;
        }
        /*if (orderStatus != '3') {
            $.modal.alertError("当前订单不是待发货");
            return;
        }*/
        //初始化地区
        initProvince();
        var url = prefix + "/getTake";
        //获取订单的收货信息
        $.post(url, {"orderNo": orderNo[0]}, function (result) {
            console.log(result)
            $("#orderNo").val(result.data.orderNo);
            $("#takeName").val(result.data.takeName);
            $("#takePhone").val(result.data.takePhone);
            $("#takeAddress").val(result.data.takeAddress);
            layer.open({
                type: 1,
                title: '修改收货地址',
                maxmin: true,
                shadeClose: false,
                area: ['850px', '600px'],
                content: $('#editArea'),
                btn: ['确定', '取消'],
                yes: function (index, layero) {
                    //收货人
                    var takeName = $("#takeName").val();
                    //收货手机号
                    var takePhone = $("#takePhone").val();
                    //收货手机号
                    var takeAddress = $("#takeAddress").val();
                    //省
                    var province = $("#province").find("option:selected").text();
                    //市
                    var city = $("#city").find("option:selected").text();
                    //区
                    var area = $("#area").find("option:selected").text();
                    var msg = '';
                    if (takeName.length == '0') {
                        msg = '收货人不能为空';
                    } else if (takePhone.length == '0') {
                        msg = '收货人手机号不能为空';
                    } else if (takeAddress.length == '0') {
                        msg = '收货人详细地址不能为空';
                    } else if (takeAddress.length < '6') {
                        msg = '收货人详细地址不能少于6个字符';
                    } else if ($("#province").val().length == '0') {
                        msg = '请选择省';
                    } else if ($("#city").val().length == '0') {
                        msg = '请选择市';
                    }
                    if (msg.length > 0) {
                        layer.msg(msg, {icon: 2, time: 1000});
                        return;
                    }
                    //修改发货地址
                    var url = prefix + "/edit";
                    var formData = $("#form1").serialize();
                    formData.area = province + "-" + city + "-" + area;
                    formData.orderNo = orderNo[0];
                    console.log(JSON.stringify(formData))
                    $.post(url, formData, function (result) {
                        if (result.code == '0') {
                            layer.msg(result.msg, {icon: 1, time: 1000});
                            $("#bootstrap-table").bootstrapTable('refresh');
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                        }
                    });
                    layer.close(index);
                }
            })
        });
    };


    /**
     * radio的监听操作
     * */
    function onchangeRadio(obj) {
        if (obj.checked) {
            //文件
            if (obj.value == '1') {
                $("#sn").show();
                $("#excel").hide();
            }
            //sn
            if (obj.value == '2') {
                $("#excel").show();
                $("#sn").hide();
            }
        }
    }

    //发货操作
    function delivery() {
        var orderNo = $.table.selectColumns("orderNo")[0];
        var customerNum = $.table.selectColumns("customerNum")[0];
        var url = prefix + "/getWlInfo"; //获取物流信息
        //点击发货填充物流信息
        $.post(url, function (result) {
            var html = "";
            result.rows.forEach(function (value, index) {
                var html = "<option value='" + value.expressId + "'>" + value.expressName + "</option>";
                $("#expressId").append(html);
            });
        });
        //默认一打开弹窗两个导入选项全部隐藏
        $("#excel").hide();
        $("#sn").hide();
        //初始化radio为未选
        radioInit();
        layer.open({
            type: 1,
            title: '发货',
            maxmin: true,
            shadeClose: false,
            area: ['1050px', '600px'],
            content: $('#delivery'),
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                var msg = '';
                if ($("#expressId option:selected").val() == '') {
                    msg = '请选择快递公司';
                } else if ($('#expressOrderNo').val() == "") {
                    msg = '快递单号不能为空';
                } else if ($('#expressOrderNo').val().length < 10) {
                    msg = '请输入正确的快递单号';
                } else if ($('#endDate').val().length == 0) {
                    msg = '请输入到期时间';
                } else if ($('#actId').val().length == 0) {
                    msg = '请选择活动';
                }
                if (msg.length > 0) {
                    layer.msg(msg, {icon: 2, time: 1000});
                    return;
                }

                var options = $("#expressId option:selected");
                //快递编号
                var expressId = options.val();
                //快递中文描述
                var expressName = options.text();
                //快递单号
                var expressOrderNo = $("#expressOrderNo").val();
                //客服备注
                var serviceRemarks = $("#service_remarks").val();
                //机具活动
                var actName = $("#actName").val();
                var actId = $("#actId").val();
                //截止时间
                var endDate = $("#endDate").val();
                //达标返现对象
                var activeType = $("#activeType").find("option:selected").val();
                var standardType = $("#standardType").find("option:selected").val();
                var stageStandardType = $("#stageStandardType").find("option:selected").val();
                var flowType = $("#flowType").find("option:selected").val();
                var serviceType = $("#serviceType").find("option:selected").val();



                //请求发货路径
                var editOrder = prefix + "/delivery"; //修改订单发货状态
                //划拨类型选择(必选一个)
                var hbType = $('input[name="hbType"]:checked ').val();
                if (typeof (hbType) == "undefined") {
                    $.modal.alertError("请选择划拨类型");
                    return;
                }

                var formData = new FormData();
                formData.append('expressId', expressId);             //快递公司
                formData.append('expressName', expressName);         //快递名称
                formData.append('expressOrderNo', expressOrderNo);   //快递单号
                formData.append('hbType', hbType);                   //划拨类型
                formData.append('serviceRemarks', serviceRemarks);   //客服备注
                formData.append('orderNo', orderNo);                 //订单编号
                formData.append('agentNum', customerNum);            //订单所属服务商
                formData.append('actId', actId);                     //活动ID
                formData.append('actName', actName);                 //活动名称
                formData.append('endDate', endDate);                 //活动到期时间
                formData.append('activeType', activeType);
                formData.append('standardType', standardType);
                formData.append('stageStandardType', stageStandardType);
                formData.append('flowType', flowType);
                formData.append('serviceType', serviceType);
                var startSn = '';
                //sn
                if (hbType == '1') {
                    startSn = $("#startSn").val()
                    if (startSn.length == 0) {
                        $.modal.alertError("请选择SN起始编号");
                        return;
                    }

                    formData.append('startSn', startSn);
                }
                //文件
                if (hbType == '2') {
                    formData.append('file', document.getElementById("file").files[0]);    //划拨类型
                }

                $.ajax({
                    url: editOrder,
                    data: formData,
                    type: "post",
                    cache: false,
                    dataType: "json",
                    cache: false,//上传文件无需缓存
                    processData: false,//用于对data参数进行序列化处理 这里必须false
                    contentType: false, //必须
                    success: function (result) {
                        if (result.code == '0') {
                            layer.msg(result.msg, {icon: 6, time: 1000});
                            $("#bootstrap-table").bootstrapTable('refresh');
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                            return;
                        }
                    },
                })
                layer.close(index);
            }
        })
    };

    /**
     * 查看物流
     */
    function queryOrder(orderNo) {
            //如果是移动端，就使用自适应大小弹窗
            var width=1200;
            var height=$(window).height() - 50;
            if ($.common.isMobile()) {
                width = 'auto';
                height = 'auto';
            }
            var url = prefix + "/queryOrderView?orderNo=" + orderNo;
            var btn = ['关闭'];
            var options = {
                title: '查看服务商',
                width: width,
                height: height,
                url: url,
                btn: btn,
                yes:function(index){
                    layer.close(index);
                }
            };
            $.modal.openOptions(options);
    }

    /**
     * 查看划拨记录
     * */
    function hb() {
        var orderNo = $.table.selectColumns("orderNo")[0];
        var customerNum = $.table.selectColumns("customerNum")[0];
        var orderStatus = $.table.selectColumns("orderStatus")[0];


        if (orderNo.length == '0') {
            layer.msg('请选择要查看的订单', {icon: 2, time: 1000});
            return;
        }
        if (orderStatus != '1' && orderStatus != '2' && orderStatus != '6') {
            $.modal.alertWarning("付款并且发货成功的订单才有划拨记录");
            return;
        }
        $.modal.open("查看划拨记录", ctx + "terminal/record/fhRecord?orderNo=" + orderNo + "&agentNum=" + customerNum, "1050", "550");
    }

    /**
     * 选择活动
     */
    function selectAct() {
        var url = ctx + "terminal/record/selectActList";
        $.modal.open("选择活动", url, '650', '450');
    }


    /**
     * 初始化radio标签全部未选
     */
    function radioInit() {
        var val = $('input:radio[name="hbType"]:checked').val();
        if (val != "undefined") {
            $('input:radio[name="hbType"]').removeAttr('checked');
        }
    };

    // 撤机
    function cj() {
        var orderNo = $.table.selectColumns("orderNo")[0]; //订单编号
        var agentNum = $.table.selectColumns("customerNum")[0]; //服务商编号
        var orderStatus = $.table.selectColumns("orderStatus")[0]; //订单状态

        if (agentNum.length == 0) {
            $.modal.alertWarning("请选择服务商编号");
            return;
        }
        if (orderNo.length == 0) {
            $.modal.alertWarning("请选择订单编号");
            return;
        }
        if (orderStatus != '1' && orderStatus != '2') {
            $.modal.alertWarning("请选择待收货或已完成订单撤机");
            return;
        }
        $.modal.confirm("确认要撤销当前订单的机具吗", function () {
            var url = ctx + "terminal/record/fhAddRevoke";
            var data = {"orderNo": orderNo, "agentNum": agentNum, "orderStatus": orderStatus};
            $.operate.post(url, data);
        });
    }


</script>
</body>
</html>